package com.lihao.sam.controller;

import com.lihao.sam.entity.ScoreSet;
import com.lihao.sam.service.intf.ScoreSetService;
import com.lihao.sam.vo.PageVo;
import com.lihao.sam.vo.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 赵申奥
 * @Description:学生评分设置
 */
@RestController
@RequestMapping("/api/score/")
public class ScoreSetController {
    @Resource
    private ScoreSetService service;

    @PostMapping("add.do")
    public R add(ScoreSet scoreSet){
        return service.add(scoreSet);
    }
    @PostMapping("update.do")
    public R update(ScoreSet scoreSet){
        return service.update(scoreSet);
    }
    @PostMapping("del.do")
    public R del(int id){
        return service.delete(id);
    }
    @GetMapping("page.do")
    public PageVo page(String rule,Integer score, int page, int limit){
        return service.queryPage(rule,score,page, limit);
    }
    @PostMapping("upload.do")
    public R upload(MultipartFile file) throws IOException {
        return service.importData(file);
    }
    @GetMapping("download.do")
    public void downLoad(HttpServletResponse response) throws IOException {
        service.exportData(response);
    }

}
